﻿CREATE TABLE [fb].[User] (
    [UserId]         INT            IDENTITY (1, 1) NOT NULL,
    [Name]           NVARCHAR (200) NOT NULL,
    [Password]       NVARCHAR (200) NOT NULL,
    [Status]         INT            NOT NULL,
    [Version]        INT            NOT NULL,
    [CreatedDate]    DATETIME       NOT NULL,
    [UpdatedDate]    DATETIME       NOT NULL,
    [CounterpartyId] INT            NULL,
    CONSTRAINT [PK_fb.User] PRIMARY KEY CLUSTERED ([UserId] ASC),
    CONSTRAINT [FK_fb.User_fb.Person_CounterpartyId] FOREIGN KEY ([CounterpartyId]) REFERENCES [fb].[Person] ([CounterpartyId])
);




GO
CREATE NONCLUSTERED INDEX [IX_CounterpartyId]
    ON [fb].[User]([CounterpartyId] ASC);


GO
CREATE UNIQUE NONCLUSTERED INDEX [IX_User_Name]
    ON [fb].[User]([Name] ASC);

